package cn.modoumama.web.interceptor;

import java.util.Locale;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
import org.springframework.web.servlet.support.RequestContext;


/**
 * 类描述：设置语言<br>
 * 创建人：邓强   <br>
 * 创建时间：2017年12月1日 上午10:31:02    <br> 
 * 修改人：  <br>
 * 修改时间：2017年12月1日 上午10:31:02   <br>  
 * 修改备注：     <br>
 * @version   V1.0
 */
public class LangInterceptor extends HandlerInterceptorAdapter {
    protected static final Logger logger = LoggerFactory.getLogger(LangInterceptor.class);

	@Override
	public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)throws Exception {
		RequestContext requestContext = new RequestContext(request);
        Locale locale = requestContext.getLocale();
        request.setAttribute("lang", locale.toString());
		return super.preHandle(request, response, handler);
	}
}
